package com.huijie.app.u.shiro.impl;

import com.huijie.app.u.service.IUserService;
import com.huijie.core.constant.BusinessConstants;
import org.jsets.shiro.handler.PasswdRetryLimitHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @ClassName: PasswdRetryLimitHandlerImpl
* @Description: 密码错误次数超限处理器实现集成自PasswdRetryLimitHandler 此处演示锁定用户
* @author Alex
* @date 2018年6月29日 下午5:11:56
*/
@Service
public class PasswdRetryLimitHandlerImpl implements PasswdRetryLimitHandler {

    private static final Logger LOGGER = LoggerFactory.getLogger(PasswdRetryLimitHandlerImpl.class);

    @Autowired
    private IUserService userService;
    
    @Override
    public void handle(String account) {
        
        try {
        	//锁定账号
			userService.updateUserStatus(Integer.valueOf(account), BusinessConstants.SYS_USER_STATUS_LOCK.getCode());
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        LOGGER.warn("账号："+account+"密码错误超过5次，已锁定");
    }
}